<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>会员管理</title>
    <meta name="description" content="这是一个会员管理页面">
    <meta name="keywords" content="会员管理">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="${contextPath}/assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="${contextPath}/assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <link rel="stylesheet" href="${contextPath}/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="${contextPath}/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="${contextPath}/assets/css/app.css">
    <script src="${contextPath}/assets/js/jquery.min.js"></script>

</head>

<body data-type="widgets">
    <script src="${contextPath}/assets/js/theme.js"></script>
    <div class="am-g tpl-g">
        <!-- 头部 -->
        <#include "/pc/common/header.html" />
        <!-- 侧边导航栏 -->
        <#include "/pc/common/left.html" />
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">
            <div class="row-content am-cf">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <ol class="am-breadcrumb widget-head">
                                <li><a href="${contextPath}/index.htm" class="am-icon-home">首页</a></li>
                                <li>佣金管理</li>
                                <li>佣金提现</li>
                            </ol>
                            <div class="widget-body  am-fr">
                                <div class="am-g">
                                    <div class="am-u-sm-4">
                                        <h2>账户佣金</h2>
                                        <p class="am-form-inline am-btn-group-xs"><e id="rebate">${account.rebate!0}</e><small>元</small>&nbsp;&nbsp;
                                            <a href="${contextPath}/rebate/list.htm" class="am-btn am-btn-secondary"><span class="am-icon-table"></span>&nbsp;明细
                                            </a>
                                        </p>
                                    </div>
                                </div>
                                <div class="am-g">
                                    <div class="am-u-sm-12 " style="border-top: 1px solid #eef1f5;padding-top: 30px">
                                        <h2>佣金提现<small><em>(提现操作将扣除${prop}%手续费)</em></small></h2>
                                        <ul class="am-nav am-nav-tabs">
                                            <li class="am-active"><a href="javascript:;">支付宝</a></li>
                                            <li><a href="javascript:;">银行卡</a></li>
                                        </ul>
                                        <div class="am-form am-form-horizontal" id="alipay">
                                            <div class="am-form-group" style="padding-top: 30px">
                                                <label class="am-form-label am-u-sm-2">提现金额</label>
                                                <div class="am-u-sm-9">
                                                    <input type="text" value="${account.rebate!0}" class="amount" placeholder="请输入金额(元)">
                                                </div>
                                                <button class="am-btn am-btn-secondary" onclick="all_b()">全部</button>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">支付宝账号</label>
                                                <div class="am-u-sm-10">
                                                    <input type="text" class="aliaccount" placeholder="请输入支付宝账号">
                                                </div>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">收款人姓名</label>
                                                <div class="am-u-sm-10">
                                                    <input type="text" class="realname" placeholder="请输入支付宝账号绑定人真实姓名">
                                                </div>
                                            </div>
                                            <div class="am-u-sm-offset-2">
                                                <div class="am-form-group">
                                                    <button type="button" class="am-btn am-btn-secondary" onclick="cash_b()">
                                                        <span class="am-icon-dollar"></span>&nbsp;提现申请
                                                    </button>
                                                    <a href="javascript:history.back();"
                                                       class="am-btn am-btn-default">返回</a>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="am-form am-form-horizontal" id="card" style="display: none">
                                            <div class="am-form-group" style="padding-top: 30px">
                                                <label class="am-form-label am-u-sm-2">提现金额</label>
                                                <div class="am-u-sm-9">
                                                    <input type="text" value="${account.rebate!0}" class="amount" placeholder="请输入金额(元)">
                                                </div>
                                                <button class="am-btn am-btn-secondary" onclick="all_b()">全部</button>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">银行名称</label>
                                                <div class="am-u-sm-10">
                                                    <select id="doc-ipt-4"  placeholder="请选择银行名称" class="bankname" style="margin-left:0px;">
                                                        <option value="">请选择</option>
                                                        ${dict.getOptions('bank_type','')}
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">银行账号</label>
                                                <div class="am-u-sm-10">
                                                    <input type="text" class="bankaccount" placeholder="请输入银行账号">
                                                </div>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">银行开户地</label>
                                                <div class="am-u-sm-10">
                                                    <input type="text" class="bankplace" placeholder="请输入银行开户地">
                                                </div>
                                            </div>
                                            <div class="am-form-group">
                                                <label class="am-form-label am-u-sm-2">收款人姓名</label>
                                                <div class="am-u-sm-10">
                                                    <input type="text" class="realname" placeholder="请输入支付宝账号绑定人真实姓名">
                                                </div>
                                            </div>
                                            <div class="am-u-sm-offset-2">
                                                <div class="am-form-group">
                                                    <button type="button" class="am-btn am-btn-secondary" onclick="cash_b()">
                                                        <span class="am-icon-dollar"></span>提现申请
                                                    </button>
                                                    <a href="javascript:history.back();"
                                                       class="am-btn am-btn-default">返回</a>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    <#include "/pc/common/alert.html" />
    <script src="${contextPath}/assets/js/amazeui.min.js"></script>
    <script src="${contextPath}/assets/js/amazeui.datatables.min.js"></script>
    <script src="${contextPath}/assets/js/dataTables.responsive.min.js"></script>
    <script src="${contextPath}/assets/js/amazeui.page.js"></script>
    <script src="${contextPath}/assets/js/app.js"></script>
    <script src="${contextPath}/assets/js/amazeui.dialog.min.js"></script>
    <script>
        //1：支付宝 2: 银行卡
        var paytype = 1;
        $(document).ready(function(){
            $(".am-nav-tabs li").click(function(){
                $(".am-nav-tabs li").removeClass("am-active");
                if($(this).find("a").text()=='支付宝'){
                    $(this).addClass("am-active");
                    $("#alipay").show();
                    $("#card").hide();
                    paytype = 1;
                }else{
                    $(this).addClass("am-active");
                    $("#alipay").hide();
                    $("#card").show();
                    paytype = 2;
                }
            });
        });
        function all_b(){
            var rebate = ($("#rebate").text())*1;
            if(paytype==1){
                $("#alipay .amount").val(rebate)
            }else{
                $("#card .amount").val(rebate)
            }
        }
        function cash_b(){
            var rebate = ($("#rebate").text())*1;
            var param   ;
            //var url = "${contextPath}/rebate/cash.htm?paytype="+paytype;
            var url = "${contextPath}/rebate/cash.htm" ;
            if(paytype==1){
                var amount = ($("#alipay .amount").val())*1;
                if(!amount || amount=='' || (rebate - amount)<0){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入小于等于账户佣金余额的提现金额"});
                    return false;
                }
                var aliaccount = $("#alipay .aliaccount").val();
                if(!aliaccount || aliaccount==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入支付宝账户"});
                    return false;
                }
                var realname = $("#alipay .realname").val();
                if(!realname || realname==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入收款人姓名"});
                    return false;
                }
                //url+="&amount="+amount+"&aliaccount="+aliaccount+"&realname="+realname;
                param = {
                    "paytype" : paytype ,
                    "amount"  : amount ,
                    "aliaccount" : aliaccount ,
                    "realname" : realname
                } ;
            }else{
                var amount = $("#card .amount").val()*1;
                if(!amount || amount=='' || (rebate - amount)<0){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入小于等于账户佣金余额的提现金额"});
                    return false;
                }
                var bankname = $("#card .bankname").val();
                if(!bankname || bankname==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请选择银行名称"});
                    return false;
                }
                var bankaccount = $("#card .bankaccount").val();
                if(!bankaccount || bankaccount==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入银行账号"});
                    return false;
                }
                var bankplace = $("#card .bankplace").val();
                if(!bankplace || bankplace==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入银行开户地"});
                    return false;
                }
                var realname = $("#card .realname").val();
                if(!realname || realname==''){
                    AMUI.dialog.alert({ title: '错误提示', content: "请输入收款人姓名"});
                    return false;
                }
                //url+="&amount="+amount+"&bankname="+bankname+"&bankaccount="+bankaccount+"&bankplace="+bankplace+"&realname="+realname;
                param = {
                    "paytype" : paytype ,
                    "amount"  : amount ,
                    "bankname" : bankname ,
                    "bankaccount" : bankaccount ,
                    "bankplace" : bankplace ,
                    "realname" : realname

                } ;
            }
            $.ajax({
                url:url,
                type:"post",
                data : param ,
                success:function (data) {
                    var json = $.parseJSON(data);
                    AMUI.dialog.alert({ title: '提示', content: json.errMessage, onConfirm: function() {
                        location.href="${contextPath}/rebate/list.htm"
                    } });
                }
            });
        }

    </script>
</body>

</html>